/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.config.javabeans;

import java.io.Serializable;

import java.util.HashMap;
import java.util.Map;


/**
 * Class corresponding to the "exportProfile" element of the exports_conf.xml file.
 * This defines the exportProfile configuration object.

 */
public class JBExportProfile implements Serializable
{
    /** List of export configurations. */
    private Map exportsMap = new HashMap();

    /** Name of the profile. */
    private String name;

    /**
     * Adds an export configuration.
     *
     * @param jbExport  The export to add.
     */
    public void addExport(JBExport jbExport)
    {
        String key = jbExport.getName().trim().toLowerCase();

        exportsMap.put(key, jbExport);
    }

    /**
     * Finds an export by name.
     *
     * @param aname  The name of the export.
     *
     * @return  The export configuration.
     */
    public JBExport findExportByName(String aname)
    {
        String key = aname.trim().toLowerCase();

        return (JBExport) exportsMap.get(key);
    }

    /**
     * Gets the set of the exports.
     *
     * @return  The exports set.
     */
    public Map getExportsMap()
    {
        return exportsMap;
    }

    /**
     * Sets the set of the exports.
     *
     * @param amap  The set of exports to set.
     */
    public void setExportsMap(Map amap)
    {
        this.exportsMap = amap;
    }

    /**
     * Gets the name of the profile.
     *
     * @return  The profile name.
     */
    public String getName()
    {
        return name;
    }

    /**
     * Sets the name of the profile.
     *
     * @param aname  The profile name to set.
     */
    public void setName(String aname)
    {
        this.name = aname;
    }

    /**
     * Gets the String representation of the object.
     *
     * @return  The String representation.
     */
    @Override
	public String toString()
    {
        StringBuffer buf = new StringBuffer();
        java.util.Iterator it = null;

        buf.append("name = ");
        buf.append(name);
        buf.append(System.getProperty("line.separator"));

        if (exportsMap != null)
        {
            buf.append("Map components of exportsMap = ");
            buf.append(System.getProperty("line.separator"));
            it = exportsMap.keySet().iterator();

            Object key;

            while (it.hasNext())
            {
                buf.append("...");
                key = it.next();
                buf.append(key);
                buf.append(" = ");
                buf.append(exportsMap.get(key));
                buf.append(System.getProperty("line.separator"));
            }
        }

        return buf.toString();
    }

}
